#include <cstring>
#include <iostream>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
using namespace std;


#define MAXVEX 100    //最大顶点数,应由用户定义
typedef struct EdgeNode  //边表结点 
{
    int adjvex;     //顶点下标
    struct EdgeNode *next;  // 指向下一个边的指针
} EdgeNode;

typedef struct VextexNode  // 顶点表结点
{
    int data;   //顶点域,存储顶点信息
    EdgeNode *firstedge;  // 边表头指针
} VextexNode, AdjList[MAXVEX];

typedef struct
{
    AdjList adjList;      //邻接表
    int numNodes, numEdges;   //图中当前顶点数和边数
} GraphAdjList;

void CreateALGraph(GraphAdjList *Gp, int numNodes)	
{                                            //存储顶点数
Gp->numNodes =numNodes; 
Gp->numEdges =5;

}

void GraphAddnodes(int i, int data,GraphAdjList *Gp)
{                                      //添加顶点名称
       Gp->adjList[i].data=data; 
   
       cout<<Gp->adjList[i].data<<endl;    
       Gp->adjList[i].firstedge = NULL;      //将边表置为空表
}

void GraphAddedges(int node1,int node2,GraphAdjList *Gp)
{
        EdgeNode *pe;
        pe = (EdgeNode *)malloc(sizeof(EdgeNode));
        pe->adjvex = node2;        //邻接序号为node2
                      //将pe的指针指向当前顶点上指向的结点
        pe->next = Gp->adjList[node1].firstedge;
        Gp->adjList[node1].firstedge = pe;    //将当前顶点的指针指向pe

        pe = (EdgeNode *)malloc(sizeof(EdgeNode));
        pe->adjvex = node1;       //将邻接表连接起来
        pe->next = Gp->adjList[node2].firstedge;
        Gp->adjList[node2].firstedge = pe;
}

void GraphPrint(int numEdges,GraphAdjList *Gp)
{
    int k;
     for (k = 0; k < numEdges; k++)/* 建立边表 */
    { 
   ///////
     }
}

int main()
{
    int i;
    char **classname;
    classname=(char **)malloc(20*sizeof(char *));
	for (i=0;i<20;i++)
		classname[i]=(char *)malloc(256*sizeof(char));
    strcpy(classname[0],"mother");
strcpy(classname[1],"father");
strcpy(classname[2],"child");
strcpy(classname[3],"grandpa");


    GraphAdjList GL;
    CreateALGraph(&GL,3);
 for(i=0;i<3;i++)
{
   GraphAddnodes(i, i,&GL);
}

 GraphAddedges(1, 3, &GL);
 GraphAddedges(2, 0, &GL);
 GraphAddedges(2, 1, &GL);

  return 0;
}

